﻿      
        
    function fnAddBasket(elemID,$obj)
    {  
                       PDID=$obj.attr('PDID');  
                       PDNAME=$obj.attr('PDNAME');
                       PRICE=$obj.attr('PRICE'); 
                       QUANTITY="1";
                       RATE=$obj.attr('RATE');
                       KINDNO=$obj.attr('KINDNO');
                       Capacity=$obj.attr('Capacity');
                       
                       DiscountPrice=$obj.attr('DiscountPrice');  
                       DiscountRate=$obj.attr('DiscountRate');
                       IsSaleOf=$obj.attr('IsSaleOf');                
                     $.ajax({ 
                               type: "GET", 
                               url: Url+"Pub/Ajax/AjaxQuery.aspx?type=querybasket&type1=addbasket&PDID="+PDID+"&PDNAME="+encodeURIComponent(PDNAME)+"&PRICE="+PRICE+"&QUANTITY="+QUANTITY+"&RATE="+RATE+"&KINDNO="+KINDNO+"&DiscountPrice="+DiscountPrice+"&DiscountRate="+DiscountRate+"&IsSaleOf="+IsSaleOf+"&Capacity="+Capacity, 
                               success: function(resp)
                               {        
                                        $("#"+elemID+"").empty().hide();                  
                                        if(resp=="ok")                                           
                                        {
                                             $obj.hide(); 
                                             $obj.parent().siblings().find(".cssCancelBasket").show();   
                                             if(KINDNO=="P")  fnMyBasket(KINDNO); 
                                             else fnMyBasketFilm(KINDNO); 
                                        }                                      
                               } 
                        });         
    }
    function fnCancelBasket(elemID,$obj)
    {   
                     PDID=$obj.attr('PDID'); 
                     KINDNO=$obj.attr('KINDNO');                   
                     $.ajax({ 
                               type: "GET", 
                               url: Url+"Pub/Ajax/AjaxQuery.aspx?type=querybasket&type1=cancelbasket&PDID="+PDID+"&KindNo="+KINDNO, 
                               success: function(resp)
                               {    
                                        $("#"+elemID+"").empty().hide();                  
                                        if(resp=="ok")   
                                        {
                                             $obj.hide(); 
                                             $obj.parent().prev().find(".cssAddBasket").show();   
                                             if(KINDNO=="P")  fnMyBasket(KINDNO); 
                                             else fnMyBasketFilm(KINDNO); 
                                        }                                      
                               } 
                        });         
    }
    
    function LoadingAjaxCart(hidElem,divLoading,obj)         
    {   
        index=parseInt(hidElem.val())+1;
        hidElem.val(index);
        elem="elem_"+index ;
        var x =  obj.offset().left;
        var y =  obj.offset().top;
        var w=obj.width();
        var h=obj.height(); 
       $("<div id='"+elem+"' class='div-loadingAbs'></div>").insertAfter(divLoading)
       .css({ 'top': y, 'left': x , 'width':w,'height':h})     
       
       return elem;    
    }   
    
    /****************************************************************/
    
    function fnAddBasketFilm(objCheck,$obj)
    {  
                
                       PDID=$obj.attr('PDID');  
                       PDNAME=$obj.attr('PDNAME');            
                       KINDNO=$obj.attr('KINDNO');
                       Capacity=$obj.attr('Capacity');
                       FilmNo=$obj.attr('FilmNo');        
                     $.ajax({ 
                               type: "GET", 
                               url: Url+"Pub/Ajax/AjaxQuery.aspx?type=querybasket&type1=addbasket&PDID="+PDID+"&PDNAME="+encodeURIComponent(PDNAME)+"&KINDNO="+KINDNO+"&Capacity="+Capacity+"&FilmNo="+FilmNo, 
                               success: function(resp)
                               {                    
                                        if(resp=="ok")                                           
                                        {   
                                             fnMyBasketFilm(KINDNO); 
                                             objCheck.attr("check","yes");
                                             objCheck.show();
                                           
                                        }                                      
                               } 
                        });  
                              
    }
    
    
    function fnCancelBasketFilm(objCheck,$obj)
    {   
                     PDID=$obj.attr('PDID'); 
                     KINDNO=$obj.attr('KINDNO');    
                          
                     $.ajax({ 
                               type: "GET", 
                               url: Url+"Pub/Ajax/AjaxQuery.aspx?type=querybasket&type1=cancelbasket&PDID="+PDID+"&KindNo="+KINDNO, 
                               success: function(resp)
                               {                        
                                        if(resp=="ok")   
                                        {    
                                             fnMyBasketFilm(KINDNO); 
                                             objCheck.attr("check","no");
                                             objCheck.hide();
                                        }                                      
                               } 
                        });         
    }
    
      

    function LoadingAjaxCartFilm(hidElem,divLoading,obj)         
    {   
        PDID=$obj.attr('PDID');  
        CAPACITY=$obj.attr('CAPACITY');          
        index=parseInt(hidElem.val())+1;
        hidElem.val(index);
        elem="elem_"+index ;
        var x =  obj.offset().left;
        var y =  obj.offset().top;
        var w=obj.width();
        var h=obj.height(); 
       $("<div  id='"+elem+"'  class='div-loadingAbsFilm'></div>").insertAfter(divLoading)
       .css({ 'top': y, 'left': x , 'width':w,'height':h})
       .attr({'check': 'yes','PDID': PDID,'CAPACITY':CAPACITY,'KindNo':'F'})       
       
       return elem;    
    }       
    
  /****************************************************************/  
